<template>
  <div>
    <Bluetable
      :tHead="tHead"
      :tData="tableData"
	  @operateClick="operateClick"
      ref="blueTable"
    ></Bluetable>
    <pagination
      :total="query.total"
      :page.sync="query.page"
      :limit.sync="query.limit"
      @pagination="getList"
    />

	<!-- 科室详情 -->
    <Lookdepart ref="Lookdepart" :dataObj.sync="ldataObj"></Lookdepart>

	<!-- 选择科室 -->
    <Distributdepart ref="Distributdepart" type="mz" :dataObj.sync="ddataObj" @distdepaChange="distdepaChange"></Distributdepart>

	<!-- 编辑药师 -->
    <Editperson ref="Editperson" :dataObj.sync="edataObj" @distdepaChange="distdepaChange"></Editperson>

	<!-- 复制科室 -->
	<Copydepart ref="Copydepart" type="mz" :dataObj.sync="cdataObj" @distdepaChange="distdepaChange"></Copydepart>
  </div>
</template>

<script>
import Lookdepart from "../components/lookDepart";
import Distributdepart from "../components/distributDepart";
import Editperson from "../components/editPerson";
import Copydepart from "../components/copyDepart";
export default {
  components: { Lookdepart, Distributdepart, Editperson, Copydepart },
  name: "Ptctable",
  props:{
	  search:{
		  type:Object
	  }
  },
  data() {
    return {
      query: {
        total: 0,
        page: 1,
        limit: 10
      },
      tHead: [
        {
          label: "操作",
          width: "300px",
          operate: ["查看科室", "科室分配", "编辑药师", "复制科室"]
        },
        {
          label: "序号",
		  index:true
        },
        {
          prop: "user_name",
          label: "登录账号"
        },
        {
          prop: "real_name",
          label: "药师姓名"
        },
        {
          prop: "state_flag",
          label: "状态"
        },
        {
          prop: "deptNames",
          label: "科室分配"
        },
        {
          prop: "create_time",
          label: "最后编辑时间"
        },
        {
          prop: "create_username",
          label: "最后编辑人"
        }
      ],
      tableData: [],
      depaCopy: false,
	  ldataObj:{},
	  ddataObj:{},
	  edataObj:{},
	  cdataObj:{}
    };
  },
  mounted(){
  	this.getList();
  },
  watch:{
  	search(){
  		this.getList();
  	}
  },
  methods: {
    async getList() {
		let res=await this.$ptc.listPharJson({
			type:"mz",
			yssrm:this.search.yssrm,
			kssrm:this.search.kssrm,
			page: this.query.page,
			pageSize: this.query.limit
		});
		for(var i=0;i<res.rows.length;i++){
			res.rows[i].state_flag=this.$utils.departSFormat(res.rows[i].state);
			res.rows[i].create_time=this.$utils.timeFormat(res.rows[i].create_time);
		}
		this.query.total=res.total;
		this.tableData=res.rows;
    },
    operateClick(item,row) {
		if (item == "查看科室") {
			this.ldataObj=row;
			this.$refs.Lookdepart.show();
		}
		if (item == "科室分配") {
			this.ddataObj=row;
			this.$refs.Distributdepart.show();
		}
		if (item == "编辑药师") {
			this.edataObj=row;
			this.$refs.Editperson.show();
		}
		if (item == "复制科室") {
			this.cdataObj=row;
			this.$refs.Copydepart.show();
		}
    },
	distdepaChange(){
		this.getList();
	}
  }
};
</script>

<style></style>
